<template>
    <view class="container">
        <view v-if="list.length > 0" class="joblist_2" v-for="(item, index) in list" :key="index">
            <view class="title_2">
                <view class="jobinfo_2">
                    <view class="jobinfoleft_2">
                        <view class="address_2">
                            <view class="jobname_2">{{ item.jobtitle }}</view>

                            <view class="moneyinfo_2">
                                <block v-if="item.money == 0">面议</block>
                                <block v-else>{{ item.money }}</block>
                            </view>
                            <view class="vprice2"></view>
                        </view>
                    </view>
                </view>

                <view class="detail_2">
                    <view class="info_2">
                        <view class="companyinfo_2" style="font-size: 0.9rem">
                            {{ item.companyname }}
                        </view>
                        <view class="jobmoney_2">
                            <view class="time_2">{{ item.createtime }}</view>
                        </view>
                    </view>
                </view>

                <view class="payitem">
                    <view v-if @tap="cancleSave" :data-id="item.id">取消收藏</view>
                    <view v-if @tap="toJobDetail" :data-id="item.jobid">查看职位</view>
                </view>
            </view>
        </view>

        <!--
      <view class="orderlist" wx:for-items="{{list}}">
        <view class="orderid">{{title[0]}}{{item.jobtitle}}</view>
        <view class="content">
                <view class="item">{{title[1]}}:{{item.companyname}}</view>
            <view class="item">联系电话:{{item.tel}}</view>
            <view class="item">负责人:{{item.mastername}}</view>
            <view class="item">创建时间:{{item.createtime}}</view>
            <view class="payitem">

            <view hidden="" bindtap='cancleSave' data-id="{{item.id}}" >取消收藏</view>
             <view hidden="" bindtap='toJob' data-id="{{item.jobid}}">{{title[2]}}</view>
            
             </view>
  
        </view>
      </view>

    -->

        <view class="nodata" v-if="list.length == 0">
            <image src="/static/imgs/icon/nodata.png"></image>
        </view>
    </view>
</template>

<script>
import { Findjob } from '../findjob/findjob-model.js';
var findjob = new Findjob(); //实例化 首页 对象
export default {
    data() {
        return {
            list: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        this.onLoadClone3389(options);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        /**
         * 生命周期函数--监听页面加载
         */
        onLoadClone3389: function (options) {
            var that = this;
            uni.setNavigationBarTitle({
                title: '我的收藏'
            });
            var params = {};
            findjob.mySavejob((data) => {
                that.setData({
                    list: data.jobsavelist
                });
            }, params);
        },

        cancleSave: function (e) {
            var that = this;
            var id = e.currentTarget.dataset.id;
            uni.showModal({
                title: '取消收藏',
                content: '确认取消收藏？',
                success: function (res) {
                    if (res.confirm) {
                        var params = {
                            id: id
                        };
                        findjob.cancleSave((data) => {
                            that.onLoadClone3389({});
                        }, params);
                    }
                }
            });
        },

        toJobDetail: function (e) {
            var id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/pages/jobdetail/index?id=' + id
            });
        }
    }
};
</script>
<style>
@import '../templates/css/index_2.css';
page {
    background: #f5f5f5;
}
.container {
    background-color: #f5f5f5;
    min-height: 100%;
}
.container .orderlist {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    margin-top: 10rpx;
}
.container .orderlist .orderid {
    border-bottom: 1rpx solid #efefef;
    padding-top: 20rpx;
    padding-bottom: 20rpx;
    padding-left: 20rpx;
    font-size: 0.8rem;
}

.container .orderlist .content {
    font-size: 0.8rem;
    border-bottom: 1rpx solid #efefef;
}
.container .orderlist .content .item {
    padding-top: 16rpx;
    padding-bottom: 16rpx;
    padding-left: 20rpx;
    border-bottom: 1rpx dotted #efefef;
    display: flex;
    flex-direction: row;
}
.payitem {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    padding-bottom: 20rpx;
    padding-top: 20rpx;
}
.payitem view {
    width: 180rpx;
    height: 60rpx;
    line-height: 60rpx;
    text-align: center;
    margin-right: 20rpx;
    border-radius: 5rpx;
    background: #3274e5;
    font-size: 0.6rem;
    color: #fff;
}
.payitem view:nth-child(1) {
    background: #e64340;
}

.intro {
    padding: 10rpx;
    font-size: 0.8rem;
}

.nodata {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;

    margin-top: 300rpx;
}
.nodata image {
    width: 150rpx;
    height: 150rpx;
}
</style>
